/*
 * @Author: your name
 * @Date: 2021-12-25 14:43:47
 * @LastEditTime: 2021-12-25 17:14:18
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \yanxuan_2118\src\store\index.js
 */
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state:{
        n1:100,
        n2:200,
        s1:'hello',
        s2:'word',
        b1:true,
        b2:false
    },
    // 方法
    mutations:{
        changeS1 (state, val) {
            state.s1 = val
          },
        changeN1(state,val){
            state.n1 = val
        }
    },
    actions:{
        // actions 里面的方法 可以和 mutations 内的方法重名
        changeN1(store,val){
            setTimeout(() =>{
                store.commit('changeN1',val)
            },1000)
        }
    }
})
